package model

import (
	"manager/model/entity"
)

type AreaCreateRequest struct {
	Name string `json:"name" binding:"required"`
	Desc string `json:"desc"`
}

type AreaUpdateRequest struct {
	ID *int64 `json:"id" binding:"required"`

	Name *string `json:"name"  binding:"required"`

	Desc *string `json:"desc"`
}

type AreaQueryRequest struct {
	Name *string `json:"name"  binding:"required"`
}

type AreaListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id   int     `json:"id"`
	Name *string `json:"name"`
}

type AreaListResponse struct {
	Total int         `json:"total"`
	Data  []*AreaInfo `json:"list"`
}

type AreaInfo struct {
	ID int64 `json:"id"`

	Name string `json:"name"`

	StoreCount int64 `json:"store_count"`

	SalespersonCount int64 `json:"salesperson_count"`

	Desc string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

type AreaDeleteRequest struct {
	ID int64 `json:"id"`
}
type AreaBaseRequest struct {
	ID int64 `json:"id"`
}

func AreasEntityToDto(areas []*entity.Area) []*AreaInfo {
	out := make([]*AreaInfo, 0, len(areas))
	for _, c := range areas {
		out = append(out, AreaEntityToDto(c))
	}
	return out
}

func AreaEntityToDto(e *entity.Area) *AreaInfo {
	return &AreaInfo{

		ID: e.ID,

		Name: e.Name,

		Desc: e.Desc,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
